import request from '../../utils/school-student/request.js'

/**
 * 根据学校ID获取班级列表
 * @param {Number} schoolNum - 学校ID
 * @returns {Promise} 班级列表
 */
export function getClassListByschoolNum(schoolNum) {
  return request({
    url: 'schoolStudent/getClassListBySchoolNum',
    method: 'post',
    params: { schoolNum }
  })
}

/**
 * 根据班级ID获取学生列表
 * @param {Number} classId - 班级ID
 * @returns {Promise} 学生列表
 */
export function getStudentListByClassId(classId) {
  return request({
    url: 'schoolStudent/getStudentListByClassId',
    method: 'post',
    params: { classId }
  })
}

/**
 * 编辑班级信息
 * @param {Number} classId - 班级ID
 * @param {Object} params - 班级信息参数
 * @returns {Promise} 操作结果
 */
export function updateClass(classId, params) {
  return request({
    url: 'schoolStudent/updateClass',
    method: 'post',
    params: { classId },
    data: params
  })
}

/**
 * 删除班级
 * @param {Number} classId - 班级ID
 * @returns {Promise} 操作结果
 */
export function deleteClass(classId) {
  return request({
    url: 'schoolStudent/deleteClass',
    method: 'post',
    params: { classId }
  })
}

/**
 * 删除学生
 * @param {String} studentIdCard - 学生身份证号
 * @returns {Promise} 操作结果
 */
export function deleteStudent(studentIdCard) {
  return request({
    url: 'schoolStudent/deleteStudent',
    method: 'post',
    params: { studentIdCard }
  })
}

/**
 * 添加班级
 * @param {Object} classInfo - 班级信息
 * @returns {Promise} 操作结果
 */
export function addClass(classInfo) {
  return request({
    url: 'schoolStudent/addClass',
    method: 'post',
    data: classInfo
  })
}

/**
 * 添加学生
 * @param {String} studentIdCard - 学生身份证号
 * @param {Number} classId - 班级ID
 * @returns {Promise} 操作结果
 */
export function addStudent(studentIdCard, classId) {
  return request({
    url: 'schoolStudent/addStudent',
    method: 'post',
    params: { studentIdCard, classId }
  })
}

/**
 * 根据学校ID获取教师列表
 * @param {Number} schoolNum - 学校ID
 * @returns {Promise} 教师列表
 */
export function getTeacherListByschoolNum(schoolNum) {
  return request({
    url: 'schoolStudent/getTeacherListByschoolNum',
    method: 'post',
    params: { schoolNum }
  })
}

export function getTeacherListByClassId(classId) {
    return request({
        url: 'schoolStudent/getTeacherListByClassId',
        method: 'post',
        params: { classId }
    })
}

export function updateSubjectTeacherByClassId(classId, courseName, teacherId) {
    return request({
        url: 'schoolStudent/updateSubjectTeacherByClassId',
        method: 'post',
        params: { classId, courseName, teacherId }
    })
}